package com.audaque.jadmin.common.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.audaque.jadmin.common.service.BaseService;

import tk.mybatis.mapper.common.Mapper;

/**
 * @Description :
 * @FileName: BaseService.java
 * @Author :WeiHui.Zhang
 * @Data : 2015年8月12日 下午5:25:50
 * @Version:V1.00
 */
@Service
public abstract class BaseServiceImpl<T> implements BaseService<T> {

	@Autowired
	protected Mapper<T> mapper;

	public T selectByKey(Object key) {
		return mapper.selectByPrimaryKey(key);
	}

	public int save(T entity) {
		return mapper.insert(entity);
	}

	public int delete(Object key) {
		return mapper.deleteByPrimaryKey(key);
	}

	public int updateAll(T entity) {
		return mapper.updateByPrimaryKey(entity);
	}

	public int updateNotNull(T entity) {
		return mapper.updateByPrimaryKeySelective(entity);
	}

	public List<T> selectByExample(Object example) {
		return mapper.selectByExample(example);
	}

	// TODO 其他...
}
